package com.foreknow.practice.OOp;

import java.util.Scanner;

public class Test2 {
    //要开始么( y / n )
    public void decide(){
        Scanner input = new Scanner(System.in);
        System.out.println("要开始么?(y/n)");
        //接收用户的输入
        String choice = input.next();
        if (choice.equals("y")){
            return;
        }else if (choice.equals("n")){
            System.out.println("---------------");
            System.exit(0);
        }else {
            //当输入错误时
            while (true){
                System.out.println("操作错误,是否继续操作(y/n)");
                //接收用户的输入
                String choice1 = input.next();
                if (choice1.equals("y")){
                    return;
                }else if (choice1.equals("n")){
                    System.out.println("--------------");
                    System.exit(0);
                }
            }
        }
    }
}
